package controlLayer;

import java.util.ArrayList;
import java.util.List;

import dbLayer.DBTeachingBlock;
import modelLayer.TeachingBlock;

public class TeachingBlockCtrl {
	
	private DBTeachingBlock dbTeachingBlock = new DBTeachingBlock();
	
	public TeachingBlockCtrl () {
		
	}
	
	public List<TeachingBlock> findTeachingBlock (int ID, int staffID, int subjectID, int roomID) {
		
		List<TeachingBlock> resultTB = new ArrayList<>();
		
		if (ID != 0) {
			resultTB.add(dbTeachingBlock.findTeachingBlockID(ID));
		}
		else if (staffID != 0) {
			resultTB = dbTeachingBlock.findTBStaffID(staffID);
		}
		else if (subjectID != 0) {
			resultTB = dbTeachingBlock.findTBSubjectID(subjectID);
		}
		else if (roomID != 0) {
			resultTB = dbTeachingBlock.findTBRoomID(roomID);
		}
		
		return resultTB;
	}
	
	public List<TeachingBlock> getAllTeachingBlocks () {
		
		List<TeachingBlock> TBs = new ArrayList<>();
		
		TBs = dbTeachingBlock.getAllTeachingBlocks();
		
		return TBs;
	}
	
	public boolean saveTeachingBlock (TeachingBlock tb) {
		
		return dbTeachingBlock.saveTeachingBlock(tb);
		
	}
	
	public int getLatestTBID () {
		
		int maxID = 0;
		
		maxID = dbTeachingBlock.higestID();
		
		return maxID;
		
	}
	
	public void deleteTeachingBlockID (int tbID) {
		
		dbTeachingBlock.deleteTeachingBlockID(tbID);
		
	}
	
	public boolean updateTeachingBlock (TeachingBlock tb) {
		
		return dbTeachingBlock.updateTeachingBlock(tb);
		
	}
	
	public List<Integer> existingTB () {
		
		return dbTeachingBlock.getExistingTB();
		
	}
	
}
